<template>
  <div>
    <h3>SubItem组件</h3>
    <p>已知库存数: {{ num }}</p>
    <button @click="del">库存-1</button>
    <button @click="delfn">库存-5,延迟两秒</button>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions } from "vuex";
export default {
  computed: {
    ...mapState(["num"]),
  },
  methods: {
    ...mapMutations(["subNum"]),
    ...mapActions(["asyncASubNum"]),
    del() {
      this.subNum();
    },
    delfn() {
      this.asyncASubNum(5);
    },
  },
};
</script>